<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
    // // 4. 检测是否是数字，包括整数，小数
        var a = 0.1
        var b = 1.22
        var c = 122.3;
        var re =/^\d*.?\d+$/
        console.log(re.test(a))
        console.log(re.test(b))
        console.log(re.test(c))
    
    </script>
</body>
</html>